<template>
	<view class="index-box" v-if="init">
		<view class="search-box u-flex bb-plus">
			<text class="sb-text f-28">核销码</text>
			<input @confirm="search" :value="inputValue" @input='searchinput' class="sb-input ml-20"
				placeholder="请输入手机号或订单号" />
			<view class="sb-btn u-m-r-20 l1 u-flex u-row-center c-ff u-font-24" @click="search">查询</view>
			<view class="iconfont iconfont-e639 u-font-60" style="color:#E70013" @click="chooseCode"></view>
		</view>
		<view class="search-title u-font-32 fw-bold">查询结果</view>
		<view class="no-data flex-cct">
			<view class="">请在文本框输入订单取票人的手机号码</view>
			<view class="">或者客户短信收到的订单号</view>
		</view>
		<data-list ref='list' :show='false' />
	</view>
</template>

<script>
	import dataList from '../components/index.vue'
	import {
		wxScanCode
	} from '@/utils/uniPromise'
	export default {
		components: {
			dataList
		},
		onReachBottom() {
			this.$refs.list.$loadMore()
		},
		data() {
			return {
				inputValue: '',
				init: false,
			}
		},
		onLoad() {
			if (!this.vuex_user.delivery_address) {
				uni.showModal({
					content: '你还不是团长，是否申请为团长',
					success: (res) => {
						if (res.confirm) {
							this.$linkTo(`/package/userSuper/pickUp/headoapplication/index`, 'redirectTo')
						} else if (res.cancel) {
							this.uniBack()
						}
					}
				})
			} else {
				this.$loading()
				this.$GetQueryDataList('b_product_delivery_address', 1, 1, {
					manage_id: this.vuex_user.pk_id
				}).then(res => {
					this.$hide()
					if (res.data[0].status != '1') {
						uni.showModal({
							content: '你的申请信息还在审核中，请耐心等待',
							showCancel: false,
							success: (res) => {
								this.$linkTo(`/package/user/user-info/headofapplication`, 'redirectTo')

							}
						})
					} else {
						this.init = true
					}
				})
			}
		},
		methods: {
			search() {
				if (!this.inputValue) {
					this.$refs.list.dataList = []
					return this.$toast('搜索内容不能为空')
				}
				this.$refs.list.initPage({
					address: this.vuex_user.delivery_address,
					business_id: this.vuex_business.pk_id,
					name: this.inputValue
				})
			},
			searchinput(e) {
				this.inputValue = e.detail.value
			},
			chooseCode() {
				wxScanCode().then(res => {
					this.inputValue = res.result
					this.search()
				})

			}
		}
	}
</script>
<style>
	page {
		background-color: #FFFFFF;
	}
</style>
<style lang="scss" scoped>
	.index-box {
		width: 100%;
	}

	.search-box {
		width: 100%;
		padding: 50rpx 30rpx;
	}

	.sb-text {
		width: 100rpx;
		word-break: break-all;
	}

	.c-99 {
		color: #999999;
	}

	.fw-bold {
		font-weight: bold;
	}

	.sb-icon {
		width: 70rpx;
		height: 70rpx;
	}

	.c-ff {
		color: #ffffff;
	}

	.l1 {
		line-height: 1;
	}

	.flex-cct {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	.sb-input {
		flex: 1;
		width: 100%;
		padding: 0 20rpx;
		border: 1rpx solid #E70013;
		height: 88rpx;
	}

	.sb-btn {
		width: 120rpx;
		height: 92rpx;
		background-color: #E70013;
	}

	.search-title {
		width: 100%;
		padding: 30rpx;
	}

	.no-data {
		padding: 100rpx 0;
		color: #BFBFBF;
	}
</style>
